@import '../../style/themes';
@import '../../style/mixins';

@import '../../input/style/mixin';

$select: x-select;

.#{$select} {
  @include reset-component();
  position: relative;
  display: inline-block;
  width: 100%;

  &_selector {
    display: flex;
    align-items: center;
    align-content: center;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
    padding: 0 $padding-sm;
    @include input-border();

    &:active {
      background: rgba($bg-inverse, 0.2);
    }
  }

  &-focus &_selector {
    border-color: $primary-color;
  }

  &-focus {
    .#{$select}_text {
      color: $text-color-secondary;
    }
  }

  &-single &_selector {
    height: 32px;
  }

  &-multiple &_selector {
    min-height: 32px;
    // padding: 2px 4px;
  }

  &-clear {
    position: absolute;
    top: 50%;
    right: $padding-sm;
    padding: $padding-xs;
    margin-right: -$padding-xs;
    transform: translateY(-50%);
    cursor: pointer;
  }

  &-arrow {
    position: absolute;
    top: 50%;
    right: $padding-sm;
    width: 10px;
    text-align: center;
    transform: translateY(-50%);
    pointer-events: none;
  }

  &-filterable {
    cursor: text;
  }

  &-listbox {
    padding: $margin-xss 2px;
    border: $select-listbox-border;
    box-sizing: border-box;
    background-color: $select-listbox-bg;
    box-shadow: $box-shadow-w;

    &-enter-active {
      transition: box-shadow 100ms linear;
    }

    &-enter-from {
      box-shadow: 0 0 0 transparent;
    }
  }

  &-option {
    display: flex;
    align-items: center;
    padding: 0 $padding-sm - 2px;
    margin: 1px 0;
    min-height: 32px;
    cursor: default;

    &:hover {
      background-color: $select-option-hover-bg;
    }

    &:active {
      background-color: rgba($select-option-hover-bg, 0.2);
    }

    &-selected {
      background-color: rgba($select-option-selected-bg, 0.6);

      &:hover {
        background-color: rgba($select-option-selected-bg, 0.8);
      }
    }

    &-disabled {
      opacity: 0.4;
      filter: grayscale(40%);
      pointer-events: none;
    }
  }

  &-disabled {
    pointer-events: none;
  }

  &-disabled &_selector {
    color: rgba($text-color, 0.4);
    background: $input-disabled-bg;
    border-color: transparent;
  }

  &-placeholder {
    color: $text-color-secondary;
  }

  &_tag {
    margin: 2px 4px 2px 0;
    margin-right: 4px;
  }

  &_text {
    //display: flex;
    align-items: center;

    &::after {
      content: '\a0';
    }
  }

  &_search {
    flex: 1 0 30px;

    &_input {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
      border: none;
      outline: none;
      background: transparent;
      cursor: auto;
    }
  }

  &-multiple &_search {
    flex-basis: 4px;
  }

  &-single &_search {
    position: absolute;
    top: 0;
    bottom: 0;
    left: $padding-sm;
    right: $padding-sm;
  }
}
